package com.springcloud.stream.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description:
 * @Author: JXM
 * @Date: 2024-6-17 22:54
 */
@RestController
public class SendMessageController {

    @Autowired
    private Source source;

    @GetMapping("/send")
    public String send(String message){
        MessageBuilder<String> messageBuilder = MessageBuilder.withPayload(message);
        source.output().send(messageBuilder.build());
        return "send " + message;
    }
}
